import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { TaskService } from './task.service';
import { Public } from '../decorators/public.decorator';

@Public()
@Controller('task')
export class TaskController {
  constructor(private readonly taskService: TaskService) { }


  @Post('upsert')
  async upsertTask(@Body() body: {
    recordId: string;
    startDate: string;
    sendDays: number;
    interval: number;
    times: string[];
  }) {
    await this.taskService.upsertRecordTasks(
      body.recordId,
      body.startDate,
      body.sendDays,
      body.interval,
      body.times,
    );
    return { message: '任务已更新' };
  }

  @Post('delete')
  async deleteTask(@Body() body: { recordId: string }) {
    await this.taskService.deleteRecordTasks(body.recordId);
    return { message: '任务已删除' };
  }
}
